home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / GFXFX2.ZIP / FILLTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1995-02-14  |  2KB  |  62 lines

  1.  
  2. program floodfill_demo; { FILLTEST.PAS }
  3. { Mini-drawing program to demonstrate the floodfill-procedure.
  4.   Left button: draw lines
  5.   Right button: fill!
  6.   By Bas van Gaalen }
  7. uses u_vga,u_mouse,u_kb;
  8. const
  9.   drawcolor=white;
  10.   fillcolor=blue;
  11.  
  12. const
  13.   msptr:array[0..pred(5*5)] of byte=(                        { mouse pointer }
  14.     0,0,7,0,0,
  15.     0,0,15,0,0,
  16.     7,15,0,15,7,
  17.     0,0,15,0,0,
  18.     0,0,7,0,0
  19.   );
  20.  
  21. var virscr:pointer; x,y:word; first:boolean;
  22. begin
  23.   setvideo($13);
  24.   with sprite[1] do begin
  25.     xpos:=0; ypos:=0;
  26.     xsize:=5; ysize:=5;
  27.     buf:=@msptr;
  28.     seethru:=0;
  29.     transparant:=false;
  30.   end;
  31.   gm_mousewindow(5,5,315,195); { graphics mouse window }
  32.   getmem(virscr,64000);
  33.   cls(virscr,64000);
  34.   x:=0; y:=0; { last line coord }
  35.   first:=true; { first leftpressed }
  36.   repeat
  37.     vretrace;
  38.     destenation:=vidptr;
  39.     movesprabs(1,getmousex-2,getmousey-2);
  40.     putback(virscr,vidptr,1);
  41.     putsprite(1);
  42.     if leftpressed then begin
  43.       destenation:=virscr; { draw everything in virtual screen }
  44.       if first then begin
  45.         x:=getmousex; y:=getmousey;
  46.         putpixel(x,y,drawcolor);
  47.         first:=false;
  48.       end
  49.       else begin
  50.         vga_line(x,y,getmousex,getmousey,drawcolor);
  51.         x:=getmousex; y:=getmousey;
  52.       end;
  53.       flip(virscr,vidptr,64000); { make copy to visual screen }
  54.     end;
  55.   until rightpressed;
  56.   freemem(virscr,64000);
  57.   putback(virscr,vidptr,1); { clear last mousepointer }
  58.   floodfill(getmousex,getmousey,fillcolor); { go and fill! }
  59.   while not leftpressed do;
  60.   setvideo(u_lm);
  61. end.
  62.